import request from "@/utils/request.ts";
import type {menuAddOrUpdateInter, permissionMenuResponseInter} from "@/api/acl/menu/type.ts";
import type {ResponseInter} from "@/api/commonInterFace.ts";

enum Api {
    permission_url_all = '/admin/acl/permission',
    permission_url_save = '/admin/acl/permission/save',
    permission_url_update = '/admin/acl/permission/update',
    permission_url_delete = '/admin/acl/permission/remove',
}

export const reqAllPermissionMenu = () => request.get<string, permissionMenuResponseInter>(Api.permission_url_all)

export const reqMenuAddOrUpdate = (data: menuAddOrUpdateInter) => {
    if (data.id) {
        return request.put<string, ResponseInter>(Api.permission_url_update, data)
    } else {
        return request.post<string, ResponseInter>(Api.permission_url_save, data)
    }
}

export const reqDeletePermissionMenu = (id: number) => request.delete<string, ResponseInter>(`${Api.permission_url_delete}/${id}`)
